package com.my.service;

import com.my.domain.User;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

//MQ消费者
@Component
//@RocketMQMessageListener(
//        topic = "topic10",//接收topic
//        selectorExpression = "tag1 || tag2",//接收哪些tag（tag）
//        consumerGroup = "group1"//消费者组
//)
@RocketMQMessageListener(
        topic = "topic10",//接收topic
        selectorType = SelectorType.SQL92,
        selectorExpression = "age >= 18",//sql过滤语法
        consumerGroup = "group1",//消费者组
        messageModel = MessageModel.BROADCASTING //广播模式消费
)
public class DemoConsumer implements RocketMQListener<User> {

    //接收到消息业务逻辑
    @Override
    public void onMessage(User user) {
        System.out.println("接收到："+user);
    }
}
